<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 乘积小于 K 的子数组 -->
    <script>
      var numSub = function (nums, k) {
        let product = 1
        let left = 0,
          count = 0
        for (let right = 0; right < nums.length; right++) {
          product *= nums[right]
          while (left <= right && product >= k) {
            product /= nums[left++]
          }
          count += right >= left ? right - left + 1 : 0
        }
        return count
      }
      console.log(numSub([10, 5, 2, 6], 100))
    </script>
  </body>
</html>
